﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;
using Dict.Blo;

namespace UI
{
    public class FishIcon : MonoBehaviour
    {
        public TextureKit fishIcon;
        public UILabel labCount;
        public GameObject chosedImg;
        public GameObject widgetForBag;
        string m_fishId;
        public string FishId
        {
            get
            {
                return m_fishId;
            }
        }

        public delegate void ItemClickCallback(string fishId);
        public ItemClickCallback m_callback;

        System.Diagnostics.Stopwatch stopWatch;
       
        void Awake()
        {
            labCount.gameObject.SetActive(false);
        }

        public void SetFish(string id)
        {
            m_fishId = id;

            TableFishSkill fishData = DictFishBlo.GetFishSkillTable(id);

            if (fishData != null)
            {
                fishIcon.textureName = fishData.FishItemID;
            }
        }

        public void UpdateCount(string text, UIWidget.Pivot pivot = UIWidget.Pivot.Center)
        {
            labCount.gameObject.SetActive(true);
            labCount.pivot = pivot;
            labCount.text = text;
        }

        public void OnClick()
        {
            if (m_callback != null)
            {
                Debug.Log("callback in click");
                m_callback(m_fishId);
            }
        }

    }
}

